# 掌握5大金刚之string，和9字口诀：基建-增删改查操-切复
#5大金刚包括：list, tuple, str, set, dict

#基 - 1. 是一个字符串序列（sequence） 2. 基于utf-8编码 3. str
#编码：1. ASCII 2. ISO-995-1 3. ANSI 4.GBK,GB-2312 5. UTF-8
# name = '张三'
# print(name)

# for n in 'helloyuwenao':
#     print (n)

# i=0
# for n in 'hello you are the best one!':
#     if n == 'o':
#         i = i+1
# print(i)

#2建
# 2.1 简单建
# zs = '张三'
# ls = "lisi"
# wu = '''wangwu'''

#2.2 转义字符\
# zs = '张\t三'
# print(zs)

#2.3 构造方法
# score = 98.99
# score_str = str(score)
# print(score_str)
# print(type(score_str))


#3增：字符串是immutable不可修改的
# name = 'zhangsan'
# #name[-1] = 'm' #错误，不可修改
# name2 = name[:-1] + 'm'
# print(name2)

#4删、改——都不可修改immutable

#6查
#6.1 可以通过下标来访问一个字符
shame = '打工是不可能的！'
# print(shame[-1])
#6.2 子串是否存在 - membership：in, not in
#identity:is ,is not
#print(type(shame) is str)
# print('可能' in shame)

#6.3 开头，结尾
# print(shame.startswith('打工'))
# print(shame.endswith('！'))

#6.4下标 index
# print(shame.index('可能'))

#7. 操
#7.1 格式化输出
# name = 'zhangsan'
# greeting = 'hello,'+name+'吃饭了吗？'
# print(greeting)
# print(f'hello,{name},吃饭了吗？')
# g2 = 'hello,{name},{name2},吃饭了吗？'
# print(g2.format(name='nihao',name2='aya'))

#7.2 拆分
# name = '张三，李四，王五，刘二'
# for n in name.split('，'):
#     print(n)

#7.3 合并
h = 'hello'
names = ['张三','李四','王五']
print('-'.join(names))
#7.4 查找：出现次数,RE
name = '我是一只小小小小小鸟'
print(name.count('小'))
#改变大小写
zhangsan = 'zhangsan is a BAD guy'
print(zhangsan.title())
print(zhangsan.capitalize())
print(zhangsan.upper())
print(zhangsan.lower())
print(zhangsan.swapcase())
print(zhangsan.islower())

#运算
name8 = ' wangba ya '
print(name8 + name)
print(name8*8)
#去空格
print(name8)
print(name8.strip())
print(name8.lstrip())
print(name8.rstrip())
#替换
print(name.replace('小','大'))